package com.sixtwo.security.service.impl;

import com.sixtwo.security.entity.GroupMembers;
import com.sixtwo.security.dao.GroupMembersDao;
import com.sixtwo.security.service.GroupMembersService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (GroupMembers)表服务实现类
 *
 * @author zhengsh
 * @since 2021-07-01 01:44:10
 */
@Service("groupMembersService")
public class GroupMembersServiceImpl implements GroupMembersService {
    @Resource
    private GroupMembersDao groupMembersDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public GroupMembers queryById(Long id) {
        return this.groupMembersDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GroupMembers> queryAllByLimit(int offset, int limit) {
        return this.groupMembersDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param groupMembers 实例对象
     * @return 实例对象
     */
    @Override
    public GroupMembers insert(GroupMembers groupMembers) {
        this.groupMembersDao.insert(groupMembers);
        return groupMembers;
    }

    /**
     * 修改数据
     *
     * @param groupMembers 实例对象
     * @return 实例对象
     */
    @Override
    public GroupMembers update(GroupMembers groupMembers) {
        this.groupMembersDao.update(groupMembers);
        return this.queryById(groupMembers.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.groupMembersDao.deleteById(id) > 0;
    }
}
